package string;

/**
 * 字符串支持的正则表达式方法三:
 * String replaceAll(String regex,String str)
 * 当前字符串中满足正则表达式的部分替换为给定内容
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        String s = "acd123li9h576asd";

        //数字替换-QWER-
        String z = s.replaceAll("[0-9]+","-QWER-");
        System.out.println(z);

        //字母替换-QWER-
        String x = s.replaceAll("[a-z]+","-QWER-");
        System.out.println(x);
        
        //和谐用语
        String regex = "(wqnmd|cnm|dsb|nmsl|wdnmd|nmb)";
        String message = "wqnmd!你个dsb，nmsl";
        message = message.replaceAll(regex,"***");
        System.out.println(message);
    }
}
